# encoding: utf-8
class CartoesController < ApplicationController
  # GET /cartoes
  # GET /cartoes.json
  def index
    @cartoes = Cartao.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @cartoes }
    end
  end

  # GET /cartoes/1
  # GET /cartoes/1.json
  def show
    @cartao = Cartao.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @cartao }
    end
  end

	#
	#
  def delete
    @cartao = Cartao.find(params[:id])

    respond_to do |format|
      format.html
      format.json { render json: @cartao }
    end
  end

  # GET /cartoes/new
  # GET /cartoes/new.json
  def new
    @cartao = Cartao.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @cartao }
    end
  end

  # GET /cartoes/1/edit
  def edit
    @cartao = Cartao.find(params[:id])
  end

  # POST /cartoes
  # POST /cartoes.json
  def create
    @cartao = Cartao.new(params[:cartao])

    respond_to do |format|
      if @cartao.save
        format.html { redirect_to cartoes_path, notice: 'Cartão criado com sucesso' }
        format.json { render json: @cartao, status: :created, location: @cartao }
      else
        format.html { render action: "new" }
        format.json { render json: @cartao.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /cartoes/1
  # PUT /cartoes/1.json
  def update
    @cartao = Cartao.find(params[:id])

    respond_to do |format|
      if @cartao.update_attributes(params[:cartao])
        format.html { redirect_to @cartao, notice: 'Cartao was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @cartao.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /cartoes/1
  # DELETE /cartoes/1.json
  def destroy
    @cartao = Cartao.find(params[:id])
    @cartao.destroy

    respond_to do |format|
      format.html { redirect_to cartoes_url }
      format.json { head :no_content }
    end
  end
end
